package www.openteam.com.presenter.business.other;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.CustomType;
import www.openteam.com.contract.business.other.SearchCustomPMCContract;
import www.openteam.com.model.business.other.SearchPMCInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.SearchCustomPMCFragment;

/**
 * Created by hyd on 2016/10/16.
 */

public class SearchPMCPresenter extends BasePresenter<SearchCustomPMCFragment>
        implements SearchCustomPMCContract.SearchPMCPresenter {


    public void queryMoneyTypeInfo(int pageSize) {
        ((SearchPMCInfoModel) getiModelMap().get("searchPMC"))
                .queryMoneyTypeInfo(pageSize, new SearchPMCInfoModel.SearchMOnListener() {
                    @Override
                    public void queryMSuccess(CustomType customType) {
                        getIView().loadMTIData(customType);

                    }

                    @Override
                    public void queryMFail(Throwable throwable) {
                        getIView().hideCTIData(throwable);
                    }
                });

    }

    public void queryCopayTypeInfo(int pageSize) {
        ((SearchPMCInfoModel) getiModelMap().get("searchPMC"))
                .queryCopayTypeInfo(pageSize, new SearchPMCInfoModel.SearchCPOnListener() {
                    @Override
                    public void queryCPSuccess(CustomType customType) {
                        getIView().loadCpTIData(customType);
                    }

                    @Override
                    public void queryCPFail(Throwable throwable) {
                        getIView().hideCTIData(throwable);
                    }
                });
    }

    public void queryCocustomTypeInfo(int pageSize){

        ((SearchPMCInfoModel) getiModelMap().get("searchPMC"))
                .queryCocustomTypeInfo(pageSize, new SearchPMCInfoModel.SearchCTIOnListener() {
                    @Override
                    public void queryCTISuccess(CustomType customType) {

                        getIView().loadCTIData(customType);
                    }

                    @Override
                    public void queryCTIFail(Throwable throwable) {
                        getIView().hideCTIData(throwable);
                    }
                });

    }

    public void querySendTypeInfo(int pageSize){
        ((SearchPMCInfoModel) getiModelMap().get("searchPMC"))
                .querySendTypeInfo(pageSize, new SearchPMCInfoModel.SearchSOnListener() {
                    @Override
                    public void querySSuccess(CustomType customType) {
                        getIView().loadSTIData(customType);
                    }

                    @Override
                    public void querySFail(Throwable throwable) {
                        getIView().hideCTIData(throwable);
                    }
                });
    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new SearchPMCInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();

        hashMap.put("searchPMC", models[0]);


        return hashMap;
    }
}
